/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.programacao.concorrente.problema;

/**
 *
 * @author Afonso
 */
public class Semaforo {

    private int signals = 0;

    public Semaforo(int i) { //construtor: inicia o semaforo adequadamente
        //valor = i;
    } //fim do construtor

    public synchronized void P() throws InterruptedException { //ou DOWN()
        while (this.signals == 0) {
            wait();
        }

        this.signals--;
    } //fim do metodo P()

    public synchronized void V() { //ou UP()
        this.signals++;
        notify();
    } //fim do metodo V()

} //fim da classe Semaforo
